using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class accountMap : EntityTypeConfiguration<account>
    {
        public accountMap()
        {
            // Primary Key
            this.HasKey(t => t.account_name);

            // Properties
            this.Property(t => t.account_name)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.account_password)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.user_id)
                .HasMaxLength(100);

            this.Property(t => t.create_by)
                .HasMaxLength(20);

            this.Property(t => t.update_by)
                .HasMaxLength(20);

            this.Property(t => t.Comment)
                .HasMaxLength(255);

            this.Property(t => t.Email)
                .HasMaxLength(128);

            this.Property(t => t.PasswordQuestion)
                .HasMaxLength(255);

            this.Property(t => t.PasswordAnswer)
                .HasMaxLength(255);

            // Table & Column Mappings
            this.ToTable("account");
            this.Property(t => t.account_name).HasColumnName("account_name");
            this.Property(t => t.account_password).HasColumnName("account_password");
            this.Property(t => t.user_id).HasColumnName("user_id");
            this.Property(t => t.account_active_date).HasColumnName("account_active_date");
            this.Property(t => t.account_expire_date).HasColumnName("account_expire_date");
            this.Property(t => t.status).HasColumnName("status");
            this.Property(t => t.create_by).HasColumnName("create_by");
            this.Property(t => t.update_time).HasColumnName("update_time");
            this.Property(t => t.update_by).HasColumnName("update_by");
            this.Property(t => t.create_time).HasColumnName("create_time");
            this.Property(t => t.Comment).HasColumnName("Comment");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.PasswordQuestion).HasColumnName("PasswordQuestion");
            this.Property(t => t.PasswordAnswer).HasColumnName("PasswordAnswer");
            this.Property(t => t.IsApproved).HasColumnName("IsApproved");
            this.Property(t => t.LastActivityDate).HasColumnName("LastActivityDate");
            this.Property(t => t.LastLoginDate).HasColumnName("LastLoginDate");
            this.Property(t => t.LastPasswordChangedDate).HasColumnName("LastPasswordChangedDate");
            this.Property(t => t.CreationDate).HasColumnName("CreationDate");
            this.Property(t => t.IsOnLine).HasColumnName("IsOnLine");
            this.Property(t => t.IsLockedOut).HasColumnName("IsLockedOut");
            this.Property(t => t.LastLockedOutDate).HasColumnName("LastLockedOutDate");
            this.Property(t => t.FailedPasswordAttemptCount).HasColumnName("FailedPasswordAttemptCount");
            this.Property(t => t.FailedPasswordAttemptWindowStart).HasColumnName("FailedPasswordAttemptWindowStart");
            this.Property(t => t.FailedPasswordAnswerAttemptCount).HasColumnName("FailedPasswordAnswerAttemptCount");
            this.Property(t => t.FailedPasswordAnswerAttemptWindowStart).HasColumnName("FailedPasswordAnswerAttemptWindowStart");

            // Relationships
            this.HasOptional(t => t.user)
                .WithMany(t => t.accounts)
                .HasForeignKey(d => d.user_id);

        }
    }
}
